<!DOCTYPE html>
<html>
  
<!-- Mirrored from www.dba.cn/book/electron/ELECTRONKaiFa/ELECTRONWenDangFengGeZhiNan.html by HTTrack Website Copier/3.x [XR&CO'2014], Sun, 20 Mar 2022 10:24:15 GMT -->
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Electron 文档风格指南 - Electron中文手册</title>
    <link rel="stylesheet" type="text/css" href="../../skins/cms/css/min-easyui.css">
    <link rel="stylesheet" type="text/css" href="../../skins/cms/css/book.css">
    <script type="text/javascript" src="../../js/jquery.min.js"></script>
    <script type="text/javascript" src="../../skins/cms/js/m-easyui.js"></script>
    <script type="text/javascript" src="../../skins/cms/js/prettify.js"></script>
  </head>
  <body class="easyui-layout" style="text-align:left">
    <div region="north" border="false" class="group wrap header" style="height:66px;font-size:100%">
      <div class="header">
        <div class="navigation-toggle" data-tools="navigation-toggle" data-target="#navbar-1">
          <span>Electron中文手册</span>
        </div>
        <div id="elogo" class="navbar navbar-left">
          <ul>
            <li>
              <h1><a href="../index.html">Electron中文手册</a></h1>
            </li>
          </ul>
        </div>
      <div style="clear:both"></div>
    </div>
   </div>
    <div region="west" split="true" data-options="collapsedSize:0,hideExpandTool:true" title="文档目录" style="width:20%;min-width:300px;padding:5px;display:none;">
        
      <ul class="easyui-tree"> 
        <li iconcls="icon-base"><span>Electron 教程</span><ul><li iconcls="icon-gears"><a href="../ELECTRONJiaoCheng/ELECTRONJiaoChengJianJie.html">Electron 教程简介</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONKuaiSuRuMen.html">Electron 快速入门</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONZhuoMianHuanJingJiCheng.html">Electron 桌面环境集成</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONZaiXianLiXianShiJianTanCe.html">Electron 在线/离线事件探测</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONJinCheng.html">Electron 进程</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONZhiChiDeCHROMEMingLingXingKaiGuan.html">Electron 支持的 Chrome 命令行开关</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONHuanJingBianLiang.html">Electron 环境变量</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONZhiChiDePingTai.html">Electron 支持的平台</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONYingYongBuShu.html">Electron 应用部署</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONXiangMACAPPSTOREYingYongTiJiaoXiangDao.html">Electron 向Mac App Store 应用提交向导</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONYingYongDaBao.html">Electron 应用打包</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONShiYongYuanShengMoKuai.html">Electron 使用原生模块</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONZhuJinChengDiaoShi.html">Electron 主进程调试</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONShiYongSELENIUMHeWEBDRIVER.html">Electron 使用 Selenium 和 WebDriver</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONDEVTOOLSKuoZhan.html">Electron DevTools扩展</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONShiYongPEPPERFLASHChaJian.html">Electron 使用 Pepper Flash 插件</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONShiYongWIDEVINECDMChaJian.html">Electron 使用 Widevine CDM 插件</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONShuYuBiao.html">Electron 术语表</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONLiPingRan.html">Electron 离屏渲染</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONJiaoHuShiJieShiQiREPL.html">Electron 交互式解释器 (REPL)</a></li></ul></li><li iconcls="icon-base"><span>Electron API</span><ul><li iconcls="icon-gears"><a  href="../ELECTRONAPI/ELECTRONDOMFILEDuiXiang.html">Electron DOM File对象</a></li><li iconcls="icon-gears"><a  href="../ELECTRONAPI/ELECTRONDOMWEBVIEWBiaoQian.html">Electron DOM <webview> 标签</a></li><li iconcls="icon-gears"><a  href="../ELECTRONAPI/ELECTRONWINDOWOPENHanShu.html">Electron window.open 函数</a></li></ul></li><li iconcls="icon-base"><span>在主进程内可用的模块</span><ul><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONAPPMoKuai.html">Electron app 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONAUTOUPDATERMoKuai.html">Electron autoUpdater 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONBROWSERWINDOWMoKuai.html">Electron BrowserWindow 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONCONTENTTRACINGMoKuai.html">Electron contentTracing 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONDIALOGMoKuai.html">Electron dialog 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONGLOBAL-SHORTCUTMoKuai.html">Electron global-shortcut 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONIPCMAINMoKuai.html">Electron ipcMain 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONMENUMoKuai.html">Electron menu 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONMENUITEMMoKuai.html">Electron MenuItem 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONPOWERMONITORMoKuai.html">Electron powerMonitor 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONPOWERSAVEBLOCKERMoKuai.html">Electron powerSaveBlocker 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONPROTOCOLMoKuai.html">Electron protocol 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONSESSIONMoKuai.html">Electron session 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONWEBCONTENTSMoKuai.html">Electron webContents 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONTRAYMoKuai.html">Electron Tray 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONLOCALES.html">Electron Locales</a></li></ul></li><li iconcls="icon-base"><span>在渲染进程（网页）内可用的模块</span><ul><li iconcls="icon-gears"><a  href="../ZaiRanJinChengWangYeNeiKeYongDeMoKuai/ELECTRONDESKTOPCAPTURERMoKuai.html">Electron desktopCapturer 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiRanJinChengWangYeNeiKeYongDeMoKuai/ELECTRONIPCRENDERERMoKuai.html">Electron ipcRenderer 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiRanJinChengWangYeNeiKeYongDeMoKuai/ELECTRONREMOTEMoKuai.html">Electron remote 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiRanJinChengWangYeNeiKeYongDeMoKuai/ELECTRONWEBFRAMEMoKuai.html">Electron webFrame 模块</a></li></ul></li><li iconcls="icon-base"><span>两种进程都可用的模块</span><ul><li iconcls="icon-gears"><a  href="../LiangZhongJinChengDuKeYongDeMoKuai/ELECTRONCLIPBOARDMoKuai.html">Electron clipboard 模块</a></li><li iconcls="icon-gears"><a  href="../LiangZhongJinChengDuKeYongDeMoKuai/ELECTRONCRASHREPORTERMoKuai.html">Electron crashReporter 模块</a></li><li iconcls="icon-gears"><a  href="../LiangZhongJinChengDuKeYongDeMoKuai/ELECTRONNATIVEIMAGEMoKuai.html">Electron nativeImage 模块</a></li><li iconcls="icon-gears"><a  href="../LiangZhongJinChengDuKeYongDeMoKuai/ELECTRONSCREENMoKuai.html">Electron screen 模块</a></li><li iconcls="icon-gears"><a  href="../LiangZhongJinChengDuKeYongDeMoKuai/ELECTRONSHELLMoKuai.html">Electron shell 模块</a></li></ul></li><li iconcls="icon-base"><span>Electron 开发</span><ul><li iconcls="icon-gears"><a  href="ELECTRONBianMaGuiFan.html">Electron 编码规范</a></li><li iconcls="icon-gears"><a  href="ELECTRONYuanMaMuLuJieGou.html">Electron 源码目录结构</a></li><li iconcls="icon-gears"><a  href="ELECTRONHeNWJSYuanMingNODE-WEBKITZaiJiShuShangDeChaYi.html">Electron 和 NW.js (原名 node-webkit) 在技术上的差异</a></li><li iconcls="icon-gears"><a  href="ELECTRONGouJianXiTongGaiLan.html">Electron 构建系统概览</a></li><li iconcls="icon-gears"><a  href="ELECTRONGouJianBuZhouOSX.html">Electron 构建步骤 (OS X)</a></li><li iconcls="icon-gears"><a  href="ELECTRONGouJianBuZhouWINDOWS.html">Electron 构建步骤 (Windows)</a></li><li iconcls="icon-gears"><a  href="ELECTRONGouJianBuZhouLINUX.html">Electron 构建步骤 (Linux)</a></li><li iconcls="icon-gears"><a  href="ELECTRONZaiDiaoShiZhongShiYongSYMBOLSERVER.html">Electron 在调试中使用 Symbol Server</a></li><li iconcls="icon-gears"><a  href="ELECTRONChangJianWenTi.html">Electron 常见问题</a></li><li iconcls="icon-gears"><a  href="ELECTRONBanBenGuanLi.html">Electron 版本管理</a></li><li iconcls="icon-gears"><a  href="ELECTRONWINDOWTiJiaoZhiNan.html">electron window 提交指南</a></li><li iconcls="icon-gears"><a  href="ZiDongHuaChiXuJiChengXiTongCICeShi.html">自动化持续集成系统（CI）测试</a></li><li iconcls="icon-gears"><a  href="ELECTRONWenDangFengGeZhiNan.html">Electron 文档风格指南</a></li></ul></li>
      </ul>
    
    </div>
    <div region="center">
      <div id="tt" class="easyui-tabs" fit="true" border="false" plain="true">
        <div title="Electron 文档风格指南 - Electron中文手册">  
            <div class="book-content">
              
      <div style="padding:8px;"> &gt; <a href="../index.html">Electron中文手册</a> &gt; Electron 文档风格指南</div>
      <div class="content"><h2>标题</h2>
<ul>
<li>每个页面顶部必须有一个单独的 <code>＃</code> 级标题。</li>
<li>同一页面中的章节必须有 <code>##</code> 级标题。</li>
<li>子章节需要根据它们的嵌套深度增加标题中的 <code>＃</code> 数量。</li>
<li>页面标题中的所有单词首字母都必须大写，除了 “of” 和 “and” 之类的连接词。</li>
<li>只有章节标题的第一个单词首字母必须大写.</li>
</ul>
<p>举一个 <code>Quick Start</code> 的例子:</p>
<div><pre><span><span>#</span><span> </span>Quick Start</span>

...

<span><span>##</span><span> </span>Main process</span>

...

<span><span>##</span><span> </span>Renderer process</span>

...

<span><span>##</span><span> </span>Run your app</span>

...

<span><span>###</span><span> </span>Run as a distribution</span>

...

<span><span>###</span><span> </span>Manually downloaded Electron binary</span>

...</pre></div>
<p>对于 API 参考, 可以例外于这些规则.</p>
<h2>
<a href="../../markdown/index.html">markdown</a> 规则</h2>
<ul>
<li>在代码块中使用 <code>Bash</code> 而不是 <code>cmd</code>（由于语法高亮问题）.</li>
<li>行长度应该控制在80列内.</li>
<li>列表嵌套不超出2级 (由于 Markdown 渲染问题).</li>
<li>所有的 <code>js</code> 和 <code>javascript</code> 代码块均被标记为 standard-markdown.</li>
</ul>
<h2>
用词选择</h2>
<ul>
<li>在描述结果时，使用 “will” 而不是 “would”。</li>
<li>首选 "in the ___ process" 而不是 "on".</li>
</ul>
<h2>
API 参考</h2>
<p>以下规则仅适用于 API 的文档。</p>
<h3>
页面标题</h3>
<p>每个页面必须使用由 <code>require（'electron'）</code> 返回的实际对象名称作为标题，例如 <code>BrowserWindow</code>，<code>autoUpdater</code> 和 <code>session</code>。</p>
<p>在页面标题下必须是以 <code>&gt;</code> 开头的单行描述。</p>
<p>举一个 <code>session</code> 的例子:</p>
<div><pre><span><span>#</span><span> </span>session</span>

<span><span>&gt;</span> Manage browser sessions, cookies, cache, proxy settings, etc.</span></pre></div>
<h3>
模块方法和事件</h3>
<p>对于非类的模块，它们的方法和事件必须在 <code>## Methods</code> 和 <code>## Events</code> 章节中列出。</p>
<p>举一个 <code>autoUpdater</code> 的例子:</p>
<div><pre><span><span>#</span><span> </span>autoUpdater</span>

<span><span>##</span><span> </span>Events</span>

<span><span>###</span><span> </span>Event: 'error'</span>

<span><span>##</span><span> </span>Methods</span>

<span><span>###</span><span> </span><span>`autoUpdater.setFeedURL(url[, requestheaders])`</span></span></pre></div>
<h3>
类</h3>
<ul>
<li>API 类或作为模块一部分的类必须在 <code>## Class: TheClassName</code> 章节中列出.</li>
<li>一个页面可以有多个类.</li>
<li>构造函数必须用 <code>###</code> 级标题列出.</li>
<li>
静态方法 必须在 <code>### Static Methods</code> 章节中列出.</li>
<li>
实例方法 必须在 <code>### Instance Methods</code> 章节中列出.</li>
<li>所有具有返回值的方法必须用 "Returns <code>[TYPE]</code> - Return description" 的形式描述.<ul><li>如果该方法返回一个 <code>Object</code>，则可以使用冒号后跟换行符，然后使用与函数参数相同样式的属性的无序列表来指定其结构.</li></ul>
</li>
<li>实例事件必须在 <code>### Instance Events</code> 章节中列出.</li>
<li>实例属性必须在 <code>### Instance Properties</code> 章节中列出.<ul><li>实例属性必须以 "A [Property Type] ..." 开始描述.</li></ul>
</li>
</ul>
<p>这里用 <code>Session</code> 和 <code>Cookies</code> 类作为例子:</p>
<div><pre><span><span>#</span><span> </span>session</span>

<span><span>##</span><span> </span>Methods</span>

<span><span>###</span><span> </span>session.fromPartition(partition)</span>

<span><span>##</span><span> </span>Properties</span>

<span><span>###</span><span> </span>session.defaultSession</span>

<span><span>##</span><span> </span>Class: Session</span>

<span><span>###</span><span> </span>Instance Events</span>

<span><span>####</span><span> </span>Event: 'will-download'</span>

<span><span>###</span><span> </span>Instance Methods</span>

<span><span>####</span><span> </span><span>`ses.getCacheSize(callback)`</span></span>

<span><span>###</span><span> </span>Instance Properties</span>

<span><span>####</span><span> </span><span>`ses.cookies`</span></span>

<span><span>##</span><span> </span>Class: Cookies</span>

<span><span>###</span><span> </span>Instance Methods</span>

<span><span>####</span><span> </span><span>`cookies.get(filter, callback)`</span></span></pre></div>
<h3>
方法</h3>
<p>方法章节必须采用以下形式：</p>
<div><pre><span><span>###</span><span> </span><span>`objectName.methodName(required[, optional]))`</span></span>

<span>*</span> <span>`required`</span> String - A parameter description.
<span>*</span> <span>`optional`</span> Integer (optional) - Another parameter description.

...</pre></div>
<p>标题可以是 <code>###</code> 级别或 <code>####</code> 级别，具体取决于它是模块还是类的方法。</p>
<p>对于模块，<code>objectName</code> 是模块的名称。 对于类，它必须是类的实例的名称，并且不能与模块的名称相同。</p>
<p>例如，<code>session</code> 模块下的 <code>Session</code> 类的方法必须使用 <code>ses</code> 作为 <code>objectName</code> 。</p>
<p>可选参数由围绕可选参数的方括号 <code>[]</code> 表示，并且如果此可选参数跟随另一个参数，则需要逗号：</p>
<pre><code>required[, optional]
</code></pre>
<p>下面的方法是每个参数更加详细的信息。 参数的类型由常见类型表示:</p>
<ul>
<li>String</li>
<li>Number</li>
<li>Object</li>
<li>Array</li>
<li>Boolean</li>
<li>或自定义类型,就像 Electron 的 WebContent
</li>
</ul>
<p>如果参数或方法对某些平台是唯一的，那么这些平台将使用数据类型后面的空格分隔的斜体列表来表示。 值可以是 <code>macOS</code>，<code>Windows</code> 或 <code>Linux</code></p>
<div><pre><span>*</span> <span>`animate`</span> Boolean (optional) <span>_macOS_</span> <span>_Windows_</span> - Animate the thing.</pre></div>
<p><code>Array</code> 类型的参数, 必须在指定数组下面的描述中描述可能包含的元素.</p>
<p><code>Function</code> 类型参数的描述应该清楚描述它是如何被调用的，并列出将被传递给它的参数的类型.</p>
<h3>
事件</h3>
<p>事件章节必须采用以下形式:</p>
<div><pre><span><span>###</span><span> </span>Event: 'wake-up'</span>

Returns:

<span>*</span> <span>`time`</span> String

...</pre></div>
<p>标题可以是 <code>###</code> 级别或 <code>####</code> 级别，具体取决于它是模块还是类的事件。</p>
<p>事件的参数遵循与方法相同的规则.</p>
<h3>
属性</h3>
<p>属性章节必须采用以下形式:</p>
<div><pre><span><span>###</span><span> </span>session.defaultSession</span>

...</pre></div>
<p>标题可以是 <code>###</code> 级别或 <code>####</code> 级别，具体取决于它是模块还是类的属性。</p>
<h2>
文档翻译</h2>
<p>Electron 文档的翻译文件位于 <code>docs-translations</code> 目录中.</p>
<p>如要添加另一个设定集（或部分设定集）:</p>
<ul>
<li>创建以语言缩写命名的子目录。</li>
<li>翻译文件。</li>
<li>更新您的语言目录中的 <code>README.md</code> 文件以链接到已翻译的文件。</li>
<li>在 Electron 的主 README 上添加到翻译目录的链接。</li>
</ul>
<p>请注意，<code>docs-translations</code> 下的文件只能包含已被翻译的文件，不应将原始英语文件复制到那里。</p></div>
      <div class="prev-next" style="padding:8px;">上一篇：<a class="prev" href="ZiDongHuaChiXuJiChengXiTongCICeShi.html">自动化持续集成系统（CI）测试</a><br></div>
    
            </div>
        </div> 
      </div>
    </div>
  </body>

<!-- Mirrored from www.dba.cn/book/electron/ELECTRONKaiFa/ELECTRONWenDangFengGeZhiNan.html by HTTrack Website Copier/3.x [XR&CO'2014], Sun, 20 Mar 2022 10:24:15 GMT -->
</html>